package thinkingInJava.containers;
// page 517 快速报错
//: containers/FailFast.java
//Demonstrates the "fail-fast" behavior.
import java.util.*;

public class FailFast {
    public static void main(String[] args) {
        Collection<String> c = new ArrayList<String>();
        Iterator<String> it = c.iterator();
        c.add("An object");	// 应该在变动完之后再取 Iterator, 否则就会"快速报错"
        // 这个功能主要为了保证多线程下 list 正常而用的
        try {
            String s = it.next();
        } catch(ConcurrentModificationException e) {
            System.out.println(e);
        }
    }
} /* Output:
java.util.ConcurrentModificationException
 *///:~
